$(function() {
            //添加分类按钮事件
            $(`#btnAddCate`).on(`click`, function() {
                layer.open({
                    title: `添加文章分类`,
                    type: 1,
                    content: template(`dialog-add`, {}),
                    area: `500px`,
                    anim: 1,
                    success: function(layero, index) {
                        $(`#form-add`).on(`submit`, function(e) {
                            e.preventDefault();
                            const addData = $(this).serialize();
                            Ajax(`post`, `/my/article/addcates`, addData, function(res) {
                                layer.msg(res.message);
                                if (res.status) return;
                                layer.close(index);
                                getCate();
                            })
                        })
                    }
                })
            })
            getCate();

            function getCate() {
                Ajax(`get`, `/my/article/cates`, {}, function(res) {
                            $(`tbody`).html(template(`tpl-table`, res)).find(`button.btn-edit`).on(`click`, function() {
                                        const $this = $(this);
                                        Ajax(`get`, `/my/article/cates/${$this.data(`id`)}`,{},function(res){
                                        if (res.status) return layer.msg(res.message);
                                        if (!res.is_delete) {
                                            //编辑键的事件
                                            layer.open({
                                                title: `编辑文章分类信息`,
                                                type: 1,
                                                content: template(`dialog-edit`, {}),
                                                area: `500px`,
                                                anim: 1,
                                                success: function(layero, index) {
                                                    layui.form.val(`form-edit`, res.data);
                                                    $(`#form-edit`).on(`submit`, function(e) {
                                                        e.preventDefault();
                                                        const editData = $(this).serialize();
                                                        Ajax(`post`, `/my/article/updatecate`, editData, function(res) {
                                                            layer.msg(res.message);
                                                            if (res.status) return;
                                                            layer.close(index);
                                                            getCate();
                                                        })
                                                    })
                                                }
                                            });
                                        }
                                    });                                      
                                }).next(`button.btn-delete`).on(`click`, function() {
                                        const $this = $(this);
                                        // 删除键的事件
                                        layer.confirm(`确认删除？`, { icon: 3, title: `提示` }, function(index) {
                                                    Ajax(`get`, `/my/article/deletecate/${$this.data(`id`)}`,{},function(res){
                        layer.msg(res.message);
                        if (res.status) return;
                        layer.close(index);
                        getCate();
                    });
                });
            });
        });
    }

})